package com.utooo.service.supplier;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.utooo.dao.supplier.SupplierSampleFeedbackMapper;
import com.utooo.dao.supplier.SupplierSurveyMapper;
import com.utooo.dao.suppliermanage.SupplierSampleManagementMapper;
import com.utooo.dao.suppliermanage.SupplierSurveyManagementMapper;
import com.utooo.pojo.domain.supplier.SupplierSampleFeedbackDO;
import com.utooo.pojo.domain.supplier.SupplierSurveyDO;
import com.utooo.pojo.domain.suppliermanage.SupplierSampleManagementDO;
import com.utooo.pojo.domain.suppliermanage.SupplierSurveyManagementDO;
import com.utooo.pojo.dto.supplier.execution.PurchasePushDto;
import com.utooo.pojo.dto.suppliermanage.PushSampleDto;
import com.utooo.pojo.dto.suppliermanage.PushSurveyDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @Description: TODO
 * @Author SJD
 * @Date: 2025/4/28 14:36
 * @Copyright: 南京优通信息科技股份有限公司
 */
@Service
@RequiredArgsConstructor
public class SupplierManageServiceImpl implements SupplierManageService{

    private final SupplierSampleManagementMapper supplierSampleManagementMapper;
    private final SupplierSampleFeedbackMapper supplierSampleFeedbackMapper;
    private final SupplierSurveyMapper supplierSurveyMapper;
    private final SupplierSurveyManagementMapper supplierSurveyManagementMapper;

    @Override
    public Boolean pushSample(PushSampleDto param) {
        SupplierSampleFeedbackDO feedbackDO = supplierSampleFeedbackMapper.selectOne(new LambdaQueryWrapper<SupplierSampleFeedbackDO>()
                .eq(SupplierSampleFeedbackDO::getSampleNo, param.getSampleNo()));
        SupplierSampleManagementDO managementDO = BeanUtil.copyProperties(feedbackDO, SupplierSampleManagementDO.class);
        supplierSampleManagementMapper.insert(managementDO);
        return true;
    }

    @Override
    public Boolean pushSurvey(PushSurveyDto param) {
        SupplierSurveyDO supplierSurveyDO = supplierSurveyMapper.selectOne(new LambdaQueryWrapper<SupplierSurveyDO>()
                .eq(SupplierSurveyDO::getSurveyCode, param.getSurveyCode()));
        SupplierSurveyManagementDO managementDO = BeanUtil.copyProperties(supplierSurveyDO, SupplierSurveyManagementDO.class);
        supplierSurveyManagementMapper.insert(managementDO);
        return true;
    }
}
